//
//  ProtocolStream.h
//  Protocol
//
//  Created by  user on 11-1-8.
//  Copyright 2011 GuangZhouXuanWu. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MemoryStream.h"

#import "XMSGUID.h"

#define TOARRAY(buffer,nDigit,type)  memcpy(buffer,&nDigit,sizeof(type));

#define FROMARRAY(buffer,type)  *(type*)buffer;

@interface CBitConvert : NSObject

+(void)toIntBuffer:(int)nDigit inoutput:(char*)buffer;

+(int)fromIntBuffer:(char*)buffer;

+(void)toIntArray:(int)nDigit inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(int)fromIntArray:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toShortArray:(short)nDigit inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(short)fromShortArray:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toLongLongArray:(long long)nDigit inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(long long)fromLongLongArray:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toCharArray:(char)ch inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(char)fromCharArray:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toStringArray:(NSString*)str inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(NSString*)fromStringArray:(int)strencoding buffer:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toDateTimeArray:(NSDate*)datetime inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(NSDate*)fromDateTimeArray:(CMemoryStream *)buffer output:(NSUInteger*)nOffset;

+(void)toGUIDArray:(GUID)guid inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(GUID)fromGUIDArray:(CMemoryStream *)buffer output:(NSUInteger*)nOffset;

+(NSData*)fromDataArray:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

+(void)toDataArray:(NSData*)data inoutput:(CMemoryStream*)buffer output:(NSUInteger*)nOffset;

@end
